package com.sky.controller.user;

import com.sky.service.MeetingRoomService;
import com.sky.service.MeetingRoomStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
public class MeetingRoomScheduler {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Autowired
    private MeetingRoomStatusService meetingRoomStatusService;

    //@Scheduled(cron = "0 0 * * * ?")
    @Transactional
    @Scheduled(cron = "0 * * * * ?") // 每分钟执行一次
    public void checkMeetingRoomStatus() {
        meetingRoomStatusService.checkMeetingRoomStatus();
        System.out.println("定时任务执行：检查会议室状态，当前小时是" + LocalDateTime.now());
    }
}

